/*
 * 文件名：PushCarOutBillInfoRunble.java	 
 * 时     间：下午7:16:04
 * 作     者：Administrator       
 * 版     权： 2012-2022 湖南智软网络科技, 公司保留所有权利.
 * 联     系：http://www.073586.com/
 */
package com.local.manager.push;

import java.text.SimpleDateFormat;
import java.util.List;

import com.cz073586.message.websocket356.push.PushManager;
import com.cz073586.message.websocket356.transfer.TransferVo;
import com.local.entity.vo.ParkwellPayBillVo;
import com.local.entity.vo.PushCarInOrOutInfoVo;
import com.local.model.CarParkOut;
import com.local.model.Crossing;
import com.local.model.LocalStation;
import com.local.service.face.CrossingService;
import com.qianhai.common.utils.Log4jUtil;

/**
 * 类描述: 推送车出场计费信息.
 * 
 * @ClassName: PushCarOutBillInfoRunble
 * @author Administrator
 * @date 2015年9月29日 下午7:16:04
 */
public class PushCarOutBillNullInfoRunble implements Runnable
{
	
	private static Log4jUtil log = Log4jUtil
			.getLog4j(PushCarOutBillNullInfoRunble.class);
	private ParkwellPayBillVo parkwellPayBillVo;
	
	private CrossingService crossinService;
	
	private CarParkOut carParkOut;
	
	public PushCarOutBillNullInfoRunble(ParkwellPayBillVo parkwellPayBillVo,
			CrossingService crossinService, CarParkOut carParkOut)
	{
		super();
		this.parkwellPayBillVo = parkwellPayBillVo;
		this.crossinService = crossinService;
		this.carParkOut = carParkOut;
	}
	
	@Override
	public void run()
	{
		
		try
		{
			PushCarInOrOutInfoVo pushInfo = new PushCarInOrOutInfoVo();
			// 通过设备编码查询路口数 这些查询需要放入线程里。TODO 张威
			List<Crossing> crossList = crossinService
					.queryCrossingByEquimentNo(carParkOut.getEquipment());
			// 通过路口数查询需要推送多少个岗亭
			List<LocalStation> stationList = crossinService
					.queryStaionsByCrosList(crossList);
			pushInfo.setCrossList(crossList);
			pushInfo.setStationList(stationList);
			
			TransferVo<PushCarInOrOutInfoVo> trans = new TransferVo<PushCarInOrOutInfoVo>();
			trans.setEventType("showCarOutNull");
			trans.setMarkString(parkwellPayBillVo.getStationUuid());
			SimpleDateFormat format = new SimpleDateFormat(
					"yyyy-MM-dd HH:mm:ss");
			parkwellPayBillVo.setCarOutTimeString(format
					.format(parkwellPayBillVo.getCarOutTime()));
			
			pushInfo.setParkwellPayBillVo(parkwellPayBillVo);
			
			trans.setData(pushInfo);
			PushManager.instance().pushMessage(trans);
		} catch (Throwable t)
		{
			log.error("", t);
		}
	}
	
}
